package com.woniuxy.carlife.exception;

import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MaxUploadSizeExceededException;

/**
 * @ClassName: MyExceptionHandler
 * @ Description:（统一异常处理）
 * @author: yanzhongliang     
 * @date: Update in 15:42 2021/4/8
 */

@RestControllerAdvice
@Component
public class MyExceptionHandler {
//    上传文件过大时执行的异常处理
    @ExceptionHandler(MaxUploadSizeExceededException.class)
    public String exceptionHandler(MaxUploadSizeExceededException e){
        return "上传文件过大";
    }

//    异常执行后返回的状态
    @ExceptionHandler(Exception.class)
    public String exception(Exception e){

        e.printStackTrace();
        return ".........."+e.getMessage();
    }
}
